/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 保险分类服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const insuranceClassifyApi = urls.insuranceClassify
const baseUrl = insuranceClassifyApi.baseUrl
const action = insuranceClassifyApi.action

function listAll(success, complete) {
  postRequest(baseUrl + action.listAll, {}, {}, success, complete)
}

function list(param, page, pageSize, success, complete) {
  postRequest(baseUrl + action.list + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function add(param, success, complete) {
  postRequest(baseUrl + action.add, {}, param, success, complete)
}

function update(id, param, success, complete) {
  postRequest(baseUrl + action.update + id, {}, param, success, complete)
}

function setDividedStrategy(id, param, success, complete) {
  postRequest(baseUrl + action.setDividedStrategy + id, {}, param, success, complete)
}

function setUploadConstraint(id, param, success, complete) {
  postRequest(baseUrl + action.setUploadConstraint + id, {}, param, success, complete)
}

function get(id, success, complete) {
  getRequest(baseUrl + action.get + id, {}, success, complete)
}

function remove(ids, success, complete) {
  postRequest(baseUrl + action.remove, {}, ids, success, complete)
}

/**
 *
 * @param ids
 * @param success
 * @param complete
 */
function deleteSingleInsuranceClassify(id, success, complete) {
  let ids = []
  ids.push(id)
  remove(ids, success, complete)
}

export default {
  listAll,
  list,
  add,
  update,
  get,
  remove,
  deleteSingleInsuranceClassify,
  setDividedStrategy,
  setUploadConstraint
}
